home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #3 / Amiga Plus CD - 2002 - No. 03.iso / AmigaPlus / Tools / Development / envCPP31 / compilers / sas-c / rexx / makegst.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  2002-01-01  |  6.0 KB  |  266 lines

  1. /* $VER: 1.1 */
  2.  
  3. options results                             /* enable return codes     */
  4.  
  5. if (left(address(), 6) ~= "GOLDED") then    /* not started by GoldEd ? */
  6.  
  7.     address 'GOLDED.1'
  8.  
  9. 'LOCK CURRENT RELEASE=4'                    /* lock GUI, gain access   */
  10.  
  11. if (RC ~= 0) then
  12.  
  13.     exit
  14.  
  15. options failat 6                            /* ignore warnings         */
  16.  
  17. signal on syntax                            /* ensure clean exit       */
  18.  
  19. /* ---------------------- INSERT YOUR CODE HERE ---------------------- */
  20.  
  21. 'QUERY CAT'
  22.  
  23. if (RESULT = "deutsch") then do
  24.  
  25.     STRING.sSCMSGERROR = "Kann SAS/C-Message-Browser nicht starten !"
  26.     STRING.sSCOPTS     = "Es wurde keine GTS-Datei in der Projekt-|konfiguration eingestellt !"
  27.     STRING.sNOLIB      = "rexxsupport.library nicht verfügbar !"
  28.     STRING.sSRCFILE    = "Quellcode nicht gefunden !"
  29. end
  30. else do
  31.  
  32.     STRING.sSCMSGERROR = "Can not start the SAS/C message browser !"
  33.     STRING.sERROR      = "Could not start SCMSG !"
  34.     STRING.sSCOPTS     = "Project configuration does not define|a GST file !"
  35.     STRING.sNOLIB      = "rexxsupport.library not availabale !"
  36.     STRING.sSRCFILE    = "Source code not found !"
  37. end
  38.  
  39. 'QUERY PATH VAR=PATH'
  40.  
  41. 'EXPAND NAME="' || PATH || '" VAR=PATH'
  42.  
  43. R = pragma('D', PATH)
  44.  
  45. GSTFILE = ""
  46.  
  47. call readoptions("SAS/C")
  48.  
  49. if (GSTFILE ~= "") then do
  50.  
  51.     /* find a source code for GST generation (must include all headers) */
  52.  
  53.     SRCFILE="gst.c"
  54.  
  55.     if (~exists(SRCFILE)) then
  56.  
  57.         SRCFILE = "makegst.c"
  58.  
  59.     if (~exists(SRCFILE)) then
  60.  
  61.         SRCFILE = "main.c"
  62.  
  63.     if (~exists(SRCFILE)) then do
  64.  
  65.         if (show('L', "rexxsupport.library") | addlib('rexxsupport.library', 0, -30, 0)) then do
  66.  
  67.             FILES = showdir(PATH, 'FILES')
  68.  
  69.             do while (FILES ~= "")
  70.  
  71.                 parse UPPER VAR FILES NEXT FILES
  72.  
  73.                 if (index(NEXT, ".c") ~= 0) then do
  74.  
  75.                     SRCFILE = NEXT
  76.  
  77.                     leave
  78.                 end
  79.             end
  80.  
  81.         end
  82.         else
  83.             'REQUEST PROBLEM="' || STRING.sNOLIB || '"'
  84.     end
  85.  
  86.     if (exists(SRCFILE)) then do
  87.  
  88.         call run_scmsg
  89.  
  90.         /* compile file */
  91.  
  92.         'FILE DELETE FORCE NAME="' || GSTFILE || '"'
  93.  
  94.         'RUN ASYNC CMD="sc errorrexx makegst=*"' || GSTFILE || '*" *"' || SRCFILE || '*""'
  95.     end
  96.     else
  97.         'REQUEST PROBLEM="' || STRING.sSRCFILE || '"'
  98. end
  99. else
  100.     'REQUEST PROBLEM="' || STRING.sSCOPTS || '"'
  101.  
  102. /* ------------------------- END OF YOUR CODE ------------------------ */
  103.  
  104. 'UNLOCK'
  105.  
  106. exit
  107.  
  108. SYNTAX:
  109.  
  110. SAY "Error in line" SIGL ":" ERRORTEXT(RC)
  111.  
  112. 'UNLOCK'
  113.  
  114. exit
  115.  
  116. /* /// "readoptions" */
  117.  
  118. readoptions: procedure expose CONFIG. STRING. PROJECTNAME OBJFOLDER GSTFILE
  119.  
  120.     /* read compiler-specific options file in project folder (if any exists) */
  121.  
  122.     parse upper arg SOFTWARE
  123.  
  124.     if ((SOFTWARE = "") | (SOFTWARE = "SAS/C") | (SOFTWARE = "SAS/C-GNUMAKE")) then do
  125.  
  126.         if (exists("scoptions")) then do
  127.  
  128.             if open('HANDLE', "scoptions", 'READ') then do
  129.  
  130.                 do until eof('HANDLE')
  131.  
  132.                     DATA = readln('HANDLE')
  133.  
  134.                     if (upper(left(DATA, 12)) = "PROGRAMNAME=") then do
  135.  
  136.                         PROJECTNAME = compress(substr(DATA, 13), '"')
  137.                     end
  138.                     else if (left(DATA, 11) = "OBJECTNAME=") then
  139.  
  140.                         OBJFOLDER = compress(substr(DATA, 12), '"')
  141.  
  142.                     else if (left(DATA, 18) = "GLOBALSYMBOLTABLE=") then
  143.  
  144.                         GSTFILE = compress(substr(DATA, 19), '"')
  145.                 end
  146.  
  147.                 R = close('HANDLE')
  148.             end
  149.         end
  150.     end
  151.  
  152.     return
  153.  
  154. /* /// */
  155. /* /// "run_scmsg" */
  156.  
  157. run_scmsg: procedure EXPOSE STRING.
  158.  
  159.     /*  update env variable to reflect path of current project */
  160.  
  161.     'QUERY PATH VAR=PATH'
  162.  
  163.     'EXPAND NAME="' || PATH || '" VAR=PATH'
  164.  
  165.     'SET $sc/projdir "' || PATH || '"'
  166.  
  167.     /* show browser window ? */
  168.  
  169.     'QUERY OPTIONBROWSER VAR=OPTIONBROWSER'
  170.  
  171.     /* direct SCMSG to show up on our screen */
  172.  
  173.     'QUERY SCREEN VAR=PUBSCRNAME'
  174.  
  175.     if (show('P', 'SC_SCMSG')) then do
  176.  
  177.         if (OPTIONBROWSER = "TRUE") then
  178.  
  179.             address 'SC_SCMSG' 'opts screen ' || PUBSCRNAME
  180.     end
  181.     else do
  182.  
  183.         /* read and update SCMSG config file (update screen name and arexx port) */
  184.  
  185.         if (~exists("env:sc")) then
  186.  
  187.             'FILE NEWDIR NAME="env:sc"'
  188.  
  189.         LINES = 0
  190.  
  191.         if open('SCMSG', 'env:sc/scmsg', 'READ') then do
  192.  
  193.             do until eof('SCMSG')
  194.  
  195.                 DATA = readln('SCMSG')
  196.  
  197.                 parse upper var DATA COMMAND .
  198.  
  199.                 if ((COMMAND ~= "PORTNAME") & (COMMAND ~= "PUBSCREEN") & (COMMAND ~= "EDITCOMMAND") & (COMMAND ~= "GOTOFILE") & (COMMAND ~= "GOTOLINE")) then do
  200.  
  201.                     LINES = LINES + 1
  202.  
  203.                     CONFIG.LINES = DATA
  204.                 end
  205.  
  206.             end
  207.  
  208.             R = close('SCMSG')
  209.         end
  210.  
  211.         /* save updated config file (with current port/pubscreen name) */
  212.  
  213.         if open('SCMSG', 'env:sc/scmsg', 'WRITE') then do
  214.  
  215.             PORTNAME = ADDRESS()
  216.  
  217.             R = writeln('SCMSG', "PORTNAME "  || PORTNAME  )
  218.  
  219.             R = writeln('SCMSG', "PUBSCREEN " || PUBSCRNAME)
  220.  
  221.             R = writeln('SCMSG', "GOTOFILE WINDOW USE=%f FORCE")
  222.  
  223.             R = writeln('SCMSG', "GOTOLINE GOTO INDENT LINE=%l UNFOLD=TRUE")
  224.  
  225.             R = writeln('SCMSG', "EDITCOMMAND golded:ed")
  226.  
  227.             if (LINES ~= 0) then do
  228.  
  229.                 do LINE=1 to (LINES - 1)
  230.  
  231.                     R = writeln('SCMSG', CONFIG.LINE)
  232.                 end
  233.             end
  234.  
  235.             R = close('SCMSG')
  236.         end
  237.  
  238.         /* run scmsg */
  239.  
  240.         if (exists("sc:c/scmsg")) then do
  241.  
  242.             COMMANDSTRING = 'sc:c/scmsg screen "' || PUBSCRNAME || '"'
  243.  
  244.             if (OPTIONBROWSER ~= "TRUE") then
  245.  
  246.                 COMMANDSTRING = COMMANDSTRING || ' rexxonly'
  247.  
  248.             'FIX VAR=COMMANDSTRING'
  249.  
  250.             'RUN ASYNC CMD="' || COMMANDSTRING || '" WAITPORT="SC_SCMSG" SECONDS=10 DIR="' || PATH || '"'
  251.         end
  252.  
  253.         if (~show('P', 'SC_SCMSG')) then do
  254.  
  255.             'REQUEST PROBLEM="' || STRING.sSCMSGERROR || '"'
  256.  
  257.             'UNLOCK'
  258.  
  259.             exit
  260.         end
  261.     end
  262.  
  263.     return
  264.  
  265. /* /// */
  266.